<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
</head>
<body>
    <script >
       
       
       function Phone(brand,price){
           this.brand = brand;
           this.price = price;
       }

       // 静态方法与成员
       Phone.name = "123";
       Phone.age = 123;
       // 这些属性属于函数对象，而不是属于实例对象

        Phone.prototype.call = function(){

        }

        // es5 的继承

        function SmartPhone(brand,price,color){
            Phone.call(this,brand,price);
            this.color = color;
        }

        // 设置子级构造函数原型
        SmartPhone.prototype = new Phone;
        SmartPhone.prototype.constructor = SmartPhone;

        // 添加自己独有的方法
        SmartPhone.prototype.ai = function(){

        }

        /*
        es 6 的继承
        */
   
        class Phone1 {
            constructor(hrand,price){

            }

            call(){

            }

            // get 和 set
            get price(){
                console.log("123");
                return 1;
            }

            set price(newVal){
                console.log("123");
            }
        }

        let s = new Phone1();
        // 会自动调用 get price 方法
        console.log(s.price);
        //  赋值 会自动调用 set 方法
        s.price = 'free'

        // 子类
        class SmartPhone1 extends Phone1 {

            constructor(hrand,price,color,size){
                    super(hrand,price);
            }
            // 子类对父类的方法重写
            call(){
                super().call();

            }

        }

    </script>

</body>

</html>